// Written by Craig'n'Dave
using System;
// Bubble sort
namespace ConsoleApp1
{
    class Program
    {
        static string[] bubble_sort(string[] items)
        {
            int n = items.Length;
            int index;
            bool swapped = true;
            string temp;
            // Start a new pass until no swap is made
            while ((n > 0) && (swapped = true))
            {
                swapped = false;
                // Last item has bubbled to the top and no longer needs to be checked
                n = n - 1;
                // Compare all items except those already sorted
                for (index = 0; index < items.Length - 1; index++)
                {
                    if (String.Compare(items[index], items[index + 1]) > 0)
                    {
                        temp = items[index];
                        items[index] = items[index + 1];
                        items[index + 1] = temp;
                        swapped = true;
                    }
                }
            }
            return items;
        }


        // Main program starts here
        static void Main(string[] args)
        {
            string[] items = { "Florida", "Georgia", "Delaware", "Alabama", "California" };
            items = bubble_sort(items);
            Console.WriteLine(String.Join(", ", items));
        }
    }
}
